package
{
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.utils.getTimer;

	public class TickManager extends EventDispatcher
	{
		
		private var _state:int = 0;
		public function TickManager()
		{
		}
		
		public static function get instance():TickManager
		{
			if(_instance == null)
				_instance = new TickManager();
			return _instance;
		}
		
		
		public function start():void
		{
			_state = 1;
		}
		
		public function stop():void
		{
			_state = 0;
		}
		
		
		public function updateTick():void
		{
			if(_state == 1)
			{
				this.dispatchEvent(new TickEvent(TickEvent.TICK));
			}
			/*for(var i:int = 0;i<_len;i++)
			{
				//TODO:根据type进行跳帧
				_tickObject[i].update(1);
			}*/
		}
		
		
		//已过期-------------------
		public function addObject(object:ITickable):void
		{
/*			var index:int = _tickObject.indexOf(object);
			if(index==-1)
				_tickObject.push(object);
			_len = _tickObject.length;*/
		}
		
		//已过期-------------------
		public function removeObject(object:ITickable):void
		{
			/*var index:int = _tickObject.indexOf(object);
			if(index != -1)
				_tickObject.splice(index,1);
			_len = _tickObject.length;*/
		}
		
		/*private var _len:int = 0;
		private var _tickObject:Vector.<ITickable> = new Vector.<ITickable>();*/
		private static var _instance:TickManager;
	}
}